package top.fyxxxx.downloader.utils;

import java.util.HashMap;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;

public class LocalSession {
    private static HashMap<String,Object> map=new HashMap<>();
    private static WeakHashMap<String,Object> tmp=new WeakHashMap<>();
    //常驻
    public static void perm(String key,Object val){
        tmp.remove(key);
        map.put(key,val);
    }
    //暂存
    public static void temp(String key,Object val){
        map.remove(key);
        tmp.put(key,val);
    }
    public static boolean contains(String key){
        return map.containsKey(key)||tmp.containsKey(key);
    }
    public static Object get(String key){
        Object ret=map.get(key);
        if(ret!=null)return ret;
        return tmp.get(key);
    }
}
